package com.qf.service.impl;

import com.qf.entity.MallGoodsCat;
import com.qf.entity.MallGoodsTemplate;
import com.qf.mapper.GoodsCatMapper;
import com.qf.mapper.GoodsTemplateMapper;
import com.qf.service.IGoodsCatService;
import com.qf.vo.CatCascaderVO;
import com.qf.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>title: com.qf.service.impl</p>
 * <p>Company: wendao</p>
 * author zhuximing
 * date 2021/9/18
 * description:
 */
@Service
public class GoodsCatService implements IGoodsCatService {

    @Autowired
    private GoodsCatMapper goodsCatMapper;

    @Autowired
    private GoodsTemplateMapper goodsTemplateMapper;
    @Override
    public List<MallGoodsCat> selectCatListByParentId(String parentId) {
        return goodsCatMapper.findCatListByParentId(parentId);
    }

    @Override
    public List<CatCascaderVO> selectCatCascade() {
        return goodsCatMapper.findCatCascade();
    }

    @Override
    public Result save(MallGoodsCat mallGoodsCat) {
        if (mallGoodsCat == null) {
            return  new Result(false, "参数不合法");
        }
            int save = goodsCatMapper.save(mallGoodsCat);
            return new Result(save==1?true:false, save==1?"success":"fail");

    }

}